{  Statement: http://acmp.ru/?main=task&id_task=82
   Verdict: Accepted
}
uses
    SysUtils, Math;

var
    i, n, m, k : longint;
    x, y : array[0..100010] of boolean;
    
begin
    reset(input,'input.txt');
    rewrite(output,'output.txt');
    read(n, m);
    fillchar(x, sizeof(x), 0);
    fillchar(y, sizeof(y), 0);
    for i := 1 to n do begin
        read(k);
        x[k] := true;
    end;
    for i := 1 to m do begin
        read(k);
        y[k] := true;
    end;
    for i := 0 to 100000 do
        if x[i] and y[i] then write(i, ' ');
end.